from PySide6.QtWidgets import QMessageBox

class TgMessageBox:
    """A wrapper for QMessageBox to provide a consistent API."""

    @staticmethod
    def _create_and_exec(parent, title, text, icon, buttons=QMessageBox.StandardButton.Ok):
        msg_box = QMessageBox(parent)
        msg_box.setIcon(icon)
        msg_box.setWindowTitle(title)
        msg_box.setText(text)
        msg_box.setStandardButtons(buttons)
        msg_box.setStyleSheet("QLabel { background-color: transparent; }")
        return msg_box.exec()

    @staticmethod
    def information(parent, title, text):
        TgMessageBox._create_and_exec(parent, title, text, QMessageBox.Icon.Information)

    @staticmethod
    def warning(parent, title, text):
        TgMessageBox._create_and_exec(parent, title, text, QMessageBox.Icon.Warning)

    @staticmethod
    def critical(parent, title, text):
        TgMessageBox._create_and_exec(parent, title, text, QMessageBox.Icon.Critical)

    @staticmethod
    def question(parent, title, text):
        buttons = QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No
        return TgMessageBox._create_and_exec(parent, title, text, QMessageBox.Icon.Question, buttons)